package com.douqu.game.activity.manager;

import com.douqu.game.core.factory.DatabaseConfig;
import com.douqu.game.core.factory.DatabaseFactory;
import com.douqu.game.core.util.LogUtils;

import java.util.List;
import java.util.Map;

/**
 * @Author: Bean
 * @Description:
 * @Date: 2018-08-16 13:06
 */
public class FixManager
{
    public static void main(String[] args) {

//        fixCamp("slg_auth");
    }


    private static void fixCamp(String db)
    {
        LogUtils.info("开始修复阵营战数据 ------>");

        DatabaseConfig databaseConfig = new DatabaseConfig("127.0.0.1", "3306", db, "root", "123456");
        DatabaseFactory databaseFactory = new DatabaseFactory(databaseConfig);

        List<Map<String, Object>> dataList = databaseFactory.query("select * from activity_camp where id=202");
        Map<String, Object> data = dataList.get(0);

        byte[] info = (byte[]) data.get("info");
        ActivityCampManager activityCampManager = new ActivityCampManager();
        activityCampManager.loadFrom(info);

        LogUtils.info("加载成功 -> " + info.length);


        byte[] newInfo = activityCampManager.write();

        LogUtils.info("准备存储新的 -> " + newInfo.length);

//        int result = databaseFactory.execute("update activity_camp set info = ? where id = 202", newInfo);

//        LogUtils.info("保存阵营战数据成功 -> " + result);
    }
}
